package com.link.base.base.purchaseplan.controller;


import com.link.base.base.purchaseplan.model.PurchasePlan;
import com.link.base.base.purchaseplan.service.PurchasePlanService;
import com.link.core.cllog.LCLogger;
import com.link.core.basic.annotations.JsonParam;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 要货计划controller
 *
 * @author NingLanhao
 * @date 2018-11-21 12:04
 */
@Controller
@RequestMapping("/link/purchasePlan")
public class PurchasePlanController extends BasicController<PurchasePlan> {

    @Resource
    private PurchasePlanService purchasePlanService;

    @Override
    public BasicService<PurchasePlan> getBasicService() throws Exception {
        return purchasePlanService;
    }

    @RequestMapping(value = "/updateStatus")
    @ResponseBody
    public Map<String, Object> updateStatus(@JsonParam PurchasePlan entity) {
        Map<String, Object> map = new HashMap<String, Object>();
        try {
            purchasePlanService.updateStatus(entity);
            PurchasePlan newEntry = purchasePlanService.queryById(entity);
            map.put("success", true);
            map.put("newRow", newEntry);
        } catch (Exception e) {
            LCLogger.withException(e);
            map.put("success", false);
            map.put("result", e.getMessage());
        }
        return map;
    }



}
